package com.smmisia.shop.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smmisia.shop.entity.ProductCategory;
import com.smmisia.shop.exception.ProductException;
import com.smmisia.shop.service.ProductCategoryService;
import com.smmisia.shop.mapper.ProductCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import static com.smmisia.shop.exception.ProductErrorCode.CATEGORY_DOES_NOT_FOUND;


@Service
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory>
    implements ProductCategoryService{

    @Autowired
    private ProductCategoryMapper productCategoryMapper;

    @Override
    public Boolean exitsCategory(Integer categoryId) {
        ProductCategory productCategory = productCategoryMapper.selectById(categoryId);
        Assert.notNull(productCategory,()-> new ProductException(CATEGORY_DOES_NOT_FOUND));
        return true;
    }
}




